package com.situ.crm.easyexcel;

import com.alibaba.excel.EasyExcel;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;

public class EasyExcelDemo {

    @Test
    public void testWrite() {
        List<UserData> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            UserData userData = new UserData();
            userData.setId(i);
            userData.setName("hello:" + i);
            list.add(userData);
        }
        String fileName = "E:\\excel\\03.xlsx";
        //调用EasyExcel写操作
        EasyExcel.write(fileName, UserData.class).sheet("User信息").doWrite(list);
    }

    @Test
    public void testRead() {
        String fileName = "E:\\excel\\03.xlsx";
        //调用EasyExcel读操作
        EasyExcel.read(fileName, UserData.class, new EasyExcelListener()).sheet().doRead();
    }
}
